﻿@{
    ViewBag.Title = "Equipo de Medicion";
    ViewBag.slide = "false";
    ViewBag.user = "private";
    ViewBag.perfil = Session["Codigodeperfil"];
}
@section menuLateral{
    <p>
        <br />
        <br />
    </p>
    <ul>
        <li>@Html.ActionLink("Proyecto", "Index", "Proyecto")</li>
        <li>@Html.ActionLink("Tipos de Lugar", "Index", "TipodeLugar")</li>
        <li>@Html.ActionLink("Lugar", "Index", "Lugar")</li>
        <li>@Html.ActionLink("Unidades de Medida", "Index", "UnidaddeMedida")</li>
        <li>@Html.ActionLink("Variable", "Index", "Variable")</li>
        <li>@Html.ActionLink("Rango de Cualidad", "Index", "RangodeCualidad")</li>
        <li>@Html.ActionLink("Equipo de Medicion", "Index", "EquipodeMedicion")</li>
        <li>@Html.ActionLink("Detalle de Equipo", "Index", "DetalledeEquipo")</li>
        <li>@Html.ActionLink("Tipos de Muestra", "Index", "TipodeMuestra")</li>
        <li>@Html.ActionLink("Muestra", "Index", "Muestra")</li>
    </ul>
}
@section equipoMedicion {
    @using (Html.BeginForm("Insertar", "EquipodeMedicion", FormMethod.Post, new { onsubmit = "return validateForm();" }))
    {
        <p>
            <br />
        </p>
        <fieldset>
            <br />
            <p>@Html.ActionLink("Regresar", "Index")</p>
            <div id="result">
                @if (ViewData.Model.GetType() == typeof(string))
                {
                    <p>@ViewData.Model</p>
                }
                else
                {
                    <table id="tabla">
                        <thead>
                            <tr>
                                <th colspan="3">
                                    <div align="center">
                                        REGISTRO DE EQUIPO DE MEDICION</div>
                                </th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <td colspan="3">
                                    <div align="center">
                                        Registro de informacion equipo de medicion</div>
                                </td>
                            </tr>
                        </tfoot>
                        <tbody>
                            <tr>
                                <td class="color7">
                                    <label for="valor">
                                        Codigo:</label>
                                </td>
                                <td>@Html.TextBox("Identificador", null, new { placeholder = " Ingrese Numeros", autofocus = "autofocus", maxlength = "10", onkeyUp = "return ValNumero(this);" })
                                </td>
                            </tr>
                            <tr>
                                <td class="color7">
                                    <label for="nombre">
                                        Nombre:</label>
                                </td>
                                <td>@Html.TextBox("Nombre", null, new { placeholder = " Ingrese Texto", maxlength = "50", onkeypress = "return soloLetras(event)" })
                                </td>
                            </tr>
                            <tr>
                                <td class="color7">
                                    <label for="automatico">
                                        Automatico:</label>
                                </td>
                                <td>@Html.CheckBox("Automatico")
                                </td>
                            </tr>
                            <tr>
                                <td class="color7">
                                    <label for="manual">
                                        Manual:</label>
                                </td>
                                <td>@Html.CheckBox("Manual")
                                </td>
                            </tr>
                            <tr>
                                <td class="color7">
                                    <label for="responsable">
                                        Responsable:</label>
                                </td>
                                <td>@Html.TextBox("Responsable", null, new { placeholder = " Ingrese Texto", maxlength = "50", onkeypress = "return soloLetras(event)" })
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">Asociar Tipo(s) 
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    @Html.ListBox("Filtrar", (List<SelectListItem>)ViewData.Model.Tiposdemuestra, new { Name = "Tiposdemuestra" })
                                    <input type="button" name="add" value=">>" id="add" />
                                    <br />
                                    <input type="button" name="del" value="<<" id="del" />
                                </td>
                                <td>
                                    @Html.ListBox("TiposdeMuestra", new SelectList(new[] { "" }), new { style = " width: 100px" })
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div align="center">
                        <input type="submit" value="Guardar" /></div>
                    <br />
                    <div align="center">
                        @Html.ValidationMessage("Identificador")
                        <br />
                        @Html.ValidationMessage("Nombre")
                        <br />
                        @Html.ValidationMessage("Responsable")
                        <br />
                        @Html.ValidationMessage("Prueba")
                        <br />
                        @Html.ValidationMessage("Equipo")
                    </div>
                    <br />
                    <div align="center">
                        @Html.ValidationSummary(true, "Error en el Registro de Equipo de Medicion. Verifique si los campos son correctos")
                    </div>
                }
            </div>
        </fieldset>
    }
}
@section javascript {
    <script src="@Url.Content("~/Scripts/Scripts_sicom/jqueryuv.js")" type="text/javascript"></script>
    <script type="text/javascript">
        function validateForm() {
            var count = 0;
            $.each($('#TiposdeMuestra option'), function (index, value) { // loop over each option
                var src = document.getElementById("TiposdeMuestra");
                if (src.options[count].value != "") {
                    src.options[count].selected = true;
                }
                count++;
            });
        }
    
        $(document).ready(function () {
            var accion = "";
            $('#add').click(function () {

                accion = "agregar";
                listbox_moveacross("Filtrar", "TiposdeMuestra");
            });
            $("#del").click(function () {

                accion = "borrar";
                listbox_moveacross("TiposdeMuestra", "Filtrar");
            });



            function listbox_moveacross(sourceID, destID) {

                //$(boton).click(function () {
                var src = document.getElementById(sourceID);
                var dest = document.getElementById(destID);

                for (var count = 0; count < src.options.length; count++) {

                    if (src.options[count].selected == true) {
                        var option = src.options[count];

                        var newOption = document.createElement("option");
                        newOption.value = option.value;
                        newOption.text = option.text;
                        newOption.selected = true;
                        try {
                            dest.add(newOption, null); //Standard
                            src.remove(count, null);
                        } catch (error) {
                            dest.add(newOption); // IE only
                            src.remove(count);
                        }
                        count--;
                    }
                }
            }
            //}); //fin funcion click botton

        });
    </script>
}
